
var Obj = "";
document.onmouseup = MUp;
document.onmousemove = MMove;
function MDown(Object) {
	Obj = Object.id;
	document.all(Obj).setCapture();
	pX = event.x - document.all(Obj).style.pixelLeft;
	pY = event.y - document.all(Obj).style.pixelTop;
}
function MMove() {
	if (Obj != "" && document.all(Obj)) {
		document.all(Obj).style.left = event.x - pX;
		document.all(Obj).style.top = event.y - pY;
	}
}
function MUp() {
	if (Obj != "" && document.all(Obj)) {
		document.all(Obj).releaseCapture();
		Obj = "";
	}
}
function getObjectById(id) {
	if (typeof (id) != "string" || id == "") {
		return null;
	}
	if (document.all) {
		return document.all(id);
	}
	if (document.getElementById) {
		return document.getElementById(id);
	}
	try {
		return eval(id);
	}
	catch (e) {
		return null;
	}
}
function doUploadFile(pFileNameId, pSpanFileNameId) {
//	alert("11         pSpanFileNameId="+pSpanFileNameId);
//	setFormIdSrc("iframeUploadFile", "/common/preIframeUploadFile.do?pFileNameId=" + pFileNameId + "&pSpanFileNameId=" + pSpanFileNameId);
	setFormIdSrc("iframeUploadFile", "http://localhost:8080/MickBg/website/commont/fileUpload/preIframeUploadFile.jsp");
	getObjectById("mask").style.visibility = "visible";
	getObjectById("message_box").style.visibility = "visible";
}

function setFormIdValue(formId, formValue) {
	if (getObjectById(formId) != null) {
		getObjectById(formId).value = formValue;
	}
}
function setFormIdSrc(formId, formSrc) {
	if (getObjectById(formId) != null) {
		getObjectById(formId).src = formSrc;
	}
}
function setSpanIdInnerHtml(formId, innerHtml) {
	if (getObjectById(formId) != null) {
		getObjectById(formId).innerHTML = innerHtml;
		try{
			if(!aspectRatio) {
				aspectRatio = 4 + ":" + 3;
			}
			$j('#imgIcon').imgAreaSelect({ aspectRatio: aspectRatio, handles: true, onSelectEnd:function(img, selection){
				if(selection.width == 0 && selection.height == 0){
					$j("#hidImgData").val("");
				} else {
					var data = selection.x1 + ',' + selection.y1 + ',' + selection.width + ',' + selection.height + ',';
					data += $j('#imgIcon').width() + ',' + placeW + ',' + placeH;
					$j("#hidImgData").val(data);
				}
			}});
		}
		catch(e){}
	}
}
function hiddenMask(id) {
	getObjectById(id).style.visibility = "hidden";
}
function showMask(id) {
	getObjectById(id).style.visibility = "visible";
}
function hiddenAllMask() {
	hiddenMask("message_box");
	hiddenMask("mask");
}
function countStrLen(str) {
	var len = str.length;
	var reLen = 0;
	for (var i = 0; i < len; i++) {
		if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
	            // 全角    
			reLen += 2;
		} else {
			reLen++;
		}
	}
	return reLen;
}
function isNumber(oNum) {
	if (!oNum) {
		return true;
	}
	var strP = /^\d+(\.\d+)?$/;
	if (!strP.test(oNum)) {
		return false;
	}
	try {
		if (parseFloat(oNum) != oNum) {
			return false;
		}
	}
	catch (ex) {
		return false;
	}
	return true;
}
function checkLen(objId, objIdSpan, maxLength, dvalue) {
	var strLen = countStrLen(getObjectById(objId).value);
	var lenError = maxLength - strLen;
	if(lenError>=0){
		getObjectById(objIdSpan).innerHTML = "(\u8fd8\u53ef\u4ee5\u8f93\u5165" + lenError + "\u4e2a\u5b57\u7b26)";
	}else{
		getObjectById(objIdSpan).innerHTML = "(<span class='errors'>\u8fd8\u53ef\u4ee5\u8f93\u5165" + lenError + "\u4e2a\u5b57\u7b26</span>)";
	}
}
function checkIsNumber(objId, objIdSpan, dvalue) {
	var oNum=getObjectById(objId).value;
	if (!isNumber(oNum)) {
		getObjectById(objIdSpan).innerHTML = "(<span class='errors'>\u8F93\u5165\u7684"+oNum+"\u4E0D\u662F\u6570\u503C</span>)";
	}else{
		getObjectById(objIdSpan).innerHTML = dvalue;
	}
}
function dwrDeleteFile(filePathName, pFileNameId, pSpanFileNameId) {   
	FileUploadStatusMonitor.deleteFile(filePathName);
	setSpanIdInnerHtml(pSpanFileNameId, "");
	setFormIdValue(pFileNameId, "");
}

